<template>
    <div class="app-container">
        <el-form label-width="80px">
            <el-form-item label="组名称">
                <el-input v-model="group.name"></el-input>
            </el-form-item>
            <el-form-item label="组备注">
                <el-input v-model="group.remark"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="add()">添加</el-button>
                <el-button @click="back()">返回</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
    import resourceGroupApi from '../../api/resourceGroup'
    import {Message, MessageBox} from 'element-ui'


    export default {
        name: "resource-group-manager-add",
        data:function () {
            return {
                group:{
                    name:'',
                    remark:''
                }
            }
        },
        methods:{
            add:function () {
                resourceGroupApi.add(this.group)
                    .then(function (data) {
                        if (data.status == 200){
                            Message({
                                type:'success',
                                duration: 5 * 1000,
                                message:'添加成功'
                            })
                        }else{
                            Message({
                                type:'error',
                                duration: 5 * 1000,
                                message:data.msg
                            })
                        }
                    }).catch(function () {
                        Message({
                            type:'error',
                            duration: 5 * 1000,
                            message:'添加异常失败'
                        })
                    })
            },
            back:function () {
                this.$router.back(-1)
            }
        }


    }
</script>

<style scoped>

</style>
